#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2021/7/23 6:42 上午
# @Author : lihc
# @File : add_member.py
import pytest
from selenium.webdriver.common.by import By

from seleniumdemo.po.base_page import BasePage


class AddMemberPage(BasePage):
    # 用户名元素对象
    _username_ele = (By.ID, "username")
    _account_ele = (By.ID, "memberAdd_acctid")
    _phone_ele = (By.ID, "memberAdd_phone")
    _mail_ele = (By.ID, "memberAdd_mail")
    _save_ele =  (By.CSS_SELECTOR, '.js_btn_save')
    
    # 添加用户信息并保存
    def add_member(self, username, account, phone = '', mail = ''):
        '''
        跳转到通讯录列表页面
        :return:
        '''
        from seleniumdemo.po.contact_page import ContactPage

        # 输入姓名，账号，手机，邮箱 等信息
        self.find(*self._username_ele).send_keys(username)
        self.find(*self._account_ele).send_keys(account)
        self.find(*self._phone_ele).send_keys(phone)
        self.find(*self._mail_ele).send_keys(mail)

        # 点击保存按钮
        self.find(*self._save_ele).click()

        # 跳转到通讯录页面
        return ContactPage(self.driver)